/************** Guangxi *****************/
#pragma once

// #include "IdbGCellGrid.h"
#include "IdbEnum.h"
#include "contest_net.h"
#include "contest_coord.h"
#include <unordered_map>
#include <iostream>
#include <string>

namespace ieda_contest {

class ContestDataManager;
class ContestCoord;

class Grids {
public:
    // 构造函数
    Grids() = default;
    ~Grids() = default;

    // getter
    const idb::IdbTrackDirection contest_get_direction() const { return _direction; }
    const int32_t contest_get_start() const { return _start; }
    const int32_t contest_get_num() const { return _num; }
    const int32_t contest_get_space() const { return _space; }

    // setter
    void contest_set_direction(idb::IdbTrackDirection direction) { _direction = direction; }
    // void set_direction(std::string direction);
    void contest_set_start(int32_t start) { _start = start; }
    void contest_set_num(int32_t num) { _num = num; }
    void contest_set_space(int32_t space) { _space = space; }

private:
    // ContestDataManager* _data_manager = nullptr;  // 指向 DataManager 实例的指针
    idb::IdbTrackDirection _direction;
    int32_t _start;
    int32_t _num;
    int32_t _space;
};

class SingleGcellInfo {
public:
    SingleGcellInfo() = default; // 默认构造函数
    SingleGcellInfo(ContestCoord cell_coord) {_cell_coord = cell_coord; }
    ~SingleGcellInfo() = default;

    // getter
    ContestCoord get_cell_coord() {return _cell_coord; }
    int get_cell_capacity() const {return _capacity; }
    int get_cell_demand() const {return _demand; }
    int get_cell_supply() const {return _capacity - _demand; }
    void addDemand(int val) {_demand += val; }
    void addCapacity(int val) {_capacity += val; }
    bool isCellOverflow() {return get_cell_supply() < 0;}

    // setter
    void set_cell_coord(ContestCoord cell_coord) {_cell_coord = cell_coord; }
    void set_cell_capacity(int capacity) {_capacity = capacity; }
    void set_cell_demand(int demand) {_demand = demand; }
    
private:
    ContestCoord _cell_coord;
    int _capacity = -1;
    int _demand = 0;
};

} // namespace ieda_contest